function get_threads()

	for i = 1, #threads do
		--print(threads[i])

		if threads[i]:get('done') then
			local thread_id = threads[i]:get('id')+0
			for i = 1, #local_map.meta_tiles do
				if local_map.meta_tiles[id] == thread_id then

					local_map.meta_tiles[id].image = threads[i]:get('image')

				end

			end


		end

		if threads[i]:get('error') ~= nil then

			--print(threads[i]:get('error'))
		end

	end

end


function assemble_threaded_tiles()

	for i = 1, #threads do

		if threads[i]:get('done') == true then
			Tile = threads[i]:getKeys()
			print(table.tostring(Tile))
			threads[i]:set('done', false)


		end


	end


end

function thread_queue(thread)

	table.insert(thread_buffer, thread)

end

function thread_update()
	--print(#threads)

		if #threads < 4 then
			--print("threads less than 4")
			table.insert(threads, thread_buffer[1])
			table.remove(thread_buffer, 1)
			if threads[1] ~= nil then

				threads[1]:start()
			end
		end

		if threads[1] ~= nil then

			if threads[1]:peek('done') == true then

				update_meta_tiles(meta_tiles, threads[1])

				table.remove(threads, 1)
			end

		end


end

function threads_expected(num)

	for i = 1, #threads do


	end


end

